//
//  DHStyleCell.m
//  Dresshere
//
//  Created by ZhangPeng on 2018/6/9.
//  Copyright © 2018年 张朋. All rights reserved.
//

#import "DHStyleCell.h"
#import "DHLoginStyleModel.h"

@interface DHStyleCell()

@property (strong, nonatomic) DHLoginStyleModel *model;
@property (assign, nonatomic) BOOL isSelected;

@end

@implementation DHStyleCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    [self.likeButton bk_addEventHandler:^(id sender) {
        if (self.isSelected) {
            self.isSelected = NO;
            [self.likeButton setImage:[UIImage imageNamed:@"product_unlike.png"] forState:UIControlStateNormal];
        }else{
            self.isSelected = YES;
            [self.likeButton setImage:[UIImage imageNamed:@"product_like.png"] forState:UIControlStateNormal];
        }
        [self routerEventWithName:@"style_selected" userInfo:@{@"model":self.model,@"isSelected":@(self.isSelected)}];
    } forControlEvents:UIControlEventTouchUpInside];
}

- (void)updateCell:(DHLoginStyleModel *)model{
    self.model = model;
    [self.coverImageView dh_setImageURLString:model.icon];
    self.titleLabel.text = model.name;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
